// str:原始字符串，index,开始位置,changeStr，改变后的字
const changeStr = (str,index,changeStr) => {
  if (str) {
    changeStr = changeStr ? changeStr : '*';
    return str.substr(0, index) + changeStr+ str.substr(index + changeStr.length);
  }
  return str;
}
// str：字符串，frontLen：前面保留位数，endLen：后面保留位数
const plusXing = (str,frontLen,endLen) => {
  if (str) {
    let len = str.length - frontLen - endLen;
    let xing = '';
    for (let i = 0;i < len; i++) {
      xing +='*';
    }
    return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
  }
  return str;
}

const formatDate = (strTime) => {
  let date = new Date(strTime * 1000);
  let YY = date.getFullYear() + '-';
  let MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  let DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
  return YY + MM + DD;
}
 

export default {
  changeStr,
  plusXing,
  formatDate
}